//
//  Images_three_lefttwTableViewCell.m
//  ChunLaiZhuangClient
//
//  Created by zouzhisheng on 16/4/9.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "Images_three_lefttwTableViewCell.h"

@implementation Images_three_lefttwTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *identifier = @"Images_three_lefttwTableViewCell";
    // 1.缓存中取
    Images_three_lefttwTableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    // 2.创建
    if (cell == nil) {
        cell = [[Images_three_lefttwTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

        _rightBigmageView=[[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2,0, SCREEN_WIDTH/2, 108)];
        _rightBigmageView.contentMode=UIViewContentModeScaleAspectFit;
        _rightBigmageView.clipsToBounds=YES;
        
        
        _leftSmallImageView1=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/4-1, 108)];
        _leftSmallImageView1.contentMode=UIViewContentModeScaleAspectFit;
        _leftSmallImageView1.clipsToBounds=YES;
        
        
        _leftSmallImageView2=[[UIImageView alloc] initWithFrame:CGRectMake(_leftSmallImageView1.right, 0, SCREEN_WIDTH/4, 108)];
        _leftSmallImageView2.contentMode=UIViewContentModeScaleAspectFit;
        _leftSmallImageView2.clipsToBounds=YES;
        
        UIView *downLine=[[UIView alloc] initWithFrame:CGRectMake(0,_rightBigmageView.bottom+0.5, SCREEN_WIDTH, 0.5)];
        downLine.backgroundColor=[UIColor colorWithHexString:@"cacaca"];
        UIView *middleLine=[[UIView alloc] initWithFrame:CGRectMake(0,0.5,0.5, 108.5)];
        middleLine.backgroundColor=[UIColor colorWithHexString:@"cacaca"];
        UIView *middleLine1=[[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/4-0.5,0.5,0.5, 108.5)];
        middleLine1.backgroundColor=[UIColor colorWithHexString:@"cacaca"];
        [self addSubview:_rightBigmageView];
        [self addSubview:_leftSmallImageView1];
        [self addSubview:_leftSmallImageView2];
        [_rightBigmageView addSubview:middleLine];
        [self addSubview:middleLine1];
        [self addSubview:downLine];
        
        _leftSmallImageView1.tag=0;
        _leftSmallImageView2.tag=1;
        _rightBigmageView.tag=2;
        
        _leftSmallImageView1.userInteractionEnabled=YES;
        _leftSmallImageView2.userInteractionEnabled=YES;
        _rightBigmageView.userInteractionEnabled=YES;
        UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        UITapGestureRecognizer *tap2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        UITapGestureRecognizer *tap3=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [_leftSmallImageView1 addGestureRecognizer:tap1];
        [_leftSmallImageView2 addGestureRecognizer:tap2];
        [_rightBigmageView addGestureRecognizer:tap3];

        
        
    }
    return self;
}
-(void)setModel:(Images_three_left_twoModel *)model{
    _model=model;
    Images_averageModel *averageModel=model.module_data;
    [_leftSmallImageView1 sd_setImageWithURL:[NSURL URLWithString:((ImagesDetailModel *)averageModel.images[0]).image] placeholderImage:nil];
    [_leftSmallImageView2 sd_setImageWithURL:[NSURL URLWithString:((ImagesDetailModel *)averageModel.images[1]).image] placeholderImage:nil];
    [_rightBigmageView sd_setImageWithURL:[NSURL URLWithString:((ImagesDetailModel *)averageModel.images[2]).image] placeholderImage:nil];
    
}
-(void)tapAction:(UITapGestureRecognizer*)tap{
    Images_averageModel *averageModel=_model.module_data;
    ImagesDetailModel *detailModel=averageModel.images[tap.view.tag];
    [TransferManager transferToSomeViewType:detailModel.link_type linkID:detailModel.link_id  linkName:detailModel.link_name fromView:self];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
